
pro help_menu, uvalue
common slugs, status
case uvalue of
'help_imf':	helptext=['Select the type of IMF you want to use']
'help_feh':	helptext=['Select the metallicity of stars you want',$
			  'to use. Solar Metallicty in these units',$
			  'is 0.020']
'help_draw':	helptext=['The code uses one of two algorithms to',$
			  'determine stellar ages. We recommend',$
			  'the random method']
'help_maxmass': helptext=['This sets the maximum mass [in units of',$
			  'Msun] for the Cluster Mass function']
'help_minmass':helptext=['This sets the minimum mass [in units of',$
                          'Msun] for the Cluster Mass function']
'help_cmfslope':helptext=['This sets the power law index for the',$
			  'Cluster Mass Function. -2 is preferred.']
'help_sfh':	helptext=['']
'help_name':	helptext=['Name a model a unique name. Do not use spaces or',$
			  'periods. If you do not rename your model, it will',$
			  'overwrite the previous one']
'help_timestep':helptext=['The timestep of code printouts. Setting this to a smaller',$
			  'number gives more time resolution but increases computation',$
			  'time. Given in units of Myr']
'help_maxtime': helptext=['Set how long you want the simulation to run. In units of Myr']
'help_fluxes':  helptext=['Select the fluxes you want printed out. More fluxes',$
			  'result in longer computation time.']
'help_colormag': helptext=['You need at least 2 fluxes chosen to make a color magnitude ',$
			   'diagram']
'help_addcolormag': helptext=['']
'help_running':helptext=['Run Process:     Push this to run the model whose parameters you input',$
			 'View Param File: Push this to view the .param file. For information see',$
			 '                 documentation', $
			 'Copy Process:    Copy the input parameters of the selected process to the GUI',$
			 'Kill Process:    Kill an ongoing process']			
else:
endcase
;now draw the help menu
if keyword_set(helptext) then rds_popup, status.tlb, text=helptext


end

;-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
pro write_status
common slugs, status
common btns, imfbtn, fehbtn
common cmagcom, cmagnew, cmagold

if status.cmagson GT 0 then begin
if keyword_set(cmagold) then begin
status.colorchoice=strjoin(cmagold.f1+cmagold.f2, ',')
status.binflux=strjoin(cmagold.binflux, ',')
status.minflux=strjoin(cmagold.minflux, ',')
status.maxflux=strjoin(cmagold.maxflux, ',')
status.bincolor=strjoin(cmagold.bincolor, ',')
status.mincolor=strjoin(cmagold.mincolor, ',')
status.maxcolor=strjoin(cmagold.maxcolor, ',')
endif
endif else begin
status.colorchoice=''
endelse




fluxnames=['NUV','FUV','BOL','J','H','K','SDSSu','SDSSg','SDSSr','SDSSi','SDSSz',$
	'johnsonU','johnsonB','johnsonV','johnsonR','johnsonI', 'QH0']
wh=where(status.fluxes GT 0)
status.flux_choice=strjoin(fluxnames[wh], ',')

openw, lun, status.modelname+'.param', /get_lun
printf, lun, '####'
printf, lun, '#SLUG PARAMETER FILE'
printf, lun, '####'
printf, lun, '#Length of time steps (yr)'
printf, lun, 'timestep                 '+(status.timestep)+ ' #'
printf, lun, '#Maximum evolution age (yr) [<1E9]'
printf, lun, 'maxtime                  '+status.maxtime+ ' #'
printf, lun, '#Star formation rate (Msun/yr) [-1 for SFH]'
printf, lun, 'galaxy_sfr               '+status.sfr+' #'
printf, lun, '#SFH file (time[yr], sfr[M/yr]) [set -1 in SFR]'
printf, lun, 'galaxy_sfh               '+status.sfh+' #'
printf, lun, '#IMF [KROUPA, CHABRIER, SALPETER, IGIMF]'
printf, lun, 'imf_type                 '+status.imfchoice+' #'
printf, lun, '#Metallicity for stellar tracks [.0004,.001,.004,.008,.020,.040,.100]'
printf, lun, 'metallicity              '+status.fehchoice+' #'
printf, lun, '#Name of the model'
printf, lun, 'model_name               '+status.modelname+' #'
printf, lun, '#Maximum cluster mass [or if you select IGIMF, this is the time interval in years to average the SFR over to determine the maximum cluster mass]'
printf, lun, 'max_cluster_mass                 '+status.maxclustermass+' #'
printf, lun, '#Minimum cluster mass'
printf, lun, 'min_cluster_mass                 '+status.minclustermass+' #'
printf, lun, '#Slope of the cluster mass function'
printf, lun, 'slope_cmf                '+status.slopecmf+' #'
printf, lun, '#Switch between random/sequential drawing [RANDOM,SEQUENIAL]'
printf, lun, 'drawtype                 '+status.drawchoice+' #'
printf, lun, '#Fluxes to compute (comma separated) [NUV,FUV,BOL,QH0,J,H,K,SDSSu,SDSSg,SDSSr,SDSSi,SDSSz,johnsonU,johnsonB,johnsonV,johnsonR,johnsonI]'
printf, lun, 'fluxes                   '+status.flux_choice+' #'
printf, lun, '#Colors to compute from the above fluxes (comma separated) [A-C,B-C]'
printf, lun, 'colors                   '+status.colorchoice+' #'
printf, lun, '#Number of bin in flux to sample (single integer)'
printf, lun, 'binflux                  '+status.binflux+' #'
printf, lun, '#Number of bin in color to sample (single integer)'
printf, lun, 'bincolor                  '+status.bincolor+' #'
printf, lun, '#Maximum vales for colors, matching the above request (comma separated)'
printf, lun, 'maxcolor                  '+status.maxcolor+' #'
printf, lun, '#Minimum vales for colors, matching the above request (comma separated)'
printf, lun, 'mincolor                  '+status.mincolor+' #'
printf, lun, '#Maximum vales for fluxes, matching the above color request (comma separated)'
printf, lun, 'maxflux                   '+status.maxflux+' #'
printf, lun, '#Minimum vales for fluxes, matching the above color request (comma separated)'
printf, lun, 'minflux                   '+status.minflux+' #'
close, lun

end
;-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
pro gui_refresh
common slugs, status
common btns, imfbtn, fehbtn

imfbtn->setindex, where(strmatch(status.imfnames, '*'+status.imfchoice+'*'))
fehbtn->setindex, where(strmatch(status.fehnames, '*'+status.fehchoice+'*'))
if strmatch(status.drawchoice, '*random*',/fold) then widget_control, status.drawbtns[0], /set_button
if strmatch(status.drawchoice, '*seq*',/fold) then widget_control, status.drawbtns[1], /set_button
widget_control, status.cmfmaxbtn, set_value=status.maxclustermass
widget_control, status.cmfminbtn, set_value=status.minclustermass
widget_control, status.cmfslopebtn, set_value=status.slopecmf
if status.sfr GT 0 then widget_control, status.sfhbtn , set_value=status.sfr else $
             widget_control, status.sfhbtn , set_value=status.sfh
widget_control,status.outnamebtn , set_value=status.modelname
widget_control,status.timestepbtn , set_value=status.timestep
widget_control,status.maxtimebtn , set_value=status.maxtime

names=[	'nuv','fuv','bol','QH0','j','h','k',$
	'SDSSu','SDSSg','SDSSr',$
	'SDSSi','SDSSz','johnsonU','johnsonB','johnsonV',$
	'johnsonR','johnsonI']
status.fluxes=-1
for i=0, n_elements(names)-1 do begin
	widget_control, status.fluxesbtn[i], set_button=0
  if strmatch(status.flux_choice, '*'+names[i]+'*', /fold) then begin
	status.fluxes[i]*=-1
	widget_control, status.fluxesbtn[i], /set_button
  endif
endfor




end
;-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
pro parse_param, filename
common slugs, status
common btns, imfbtn, fehbtn
common cmagcom, cmagnew, cmagold

openr, lun, filename, /get_lun
dum=''
dumarr=''
  while ~EOF(lun) do begin
    readf, lun, dum
    dumarr=[dumarr, dum]
  endwhile
close, lun

wh=where(strmatch(dumarr, '#*') EQ 0 AND strmatch(dumarr, '') EQ 0)
dumarr=dumarr[wh]
status.timestep=(strsplit((strsplit(dumarr[0], /extract))[1],'#' , /extract))[0]
status.maxtime=(strsplit((strsplit(dumarr[1], /extract))[1],'#' , /extract))[0]
status.sfr=(strsplit((strsplit(dumarr[2], /extract))[1],'#' , /extract))[0]
status.sfh=(strsplit((strsplit(dumarr[3], /extract))[1],'#' , /extract))[0]
status.imfchoice=(strsplit((strsplit(dumarr[4], /extract))[1],'#' , /extract))[0]
status.fehchoice=(strsplit((strsplit(dumarr[5], /extract))[1],'#' , /extract))[0]
status.modelname=(strsplit((strsplit(dumarr[6], /extract))[1],'#' , /extract))[0]
status.maxclustermass=(strsplit((strsplit(dumarr[7], /extract))[1],'#' , /extract))[0]
status.minclustermass=(strsplit((strsplit(dumarr[8], /extract))[1],'#' , /extract))[0]
status.slopecmf=(strsplit((strsplit(dumarr[9], /extract))[1],'#' , /extract))[0]
status.drawchoice=(strsplit((strsplit(dumarr[10], /extract))[1],'#' , /extract))[0]
status.flux_choice=(strsplit((strsplit(dumarr[11], /extract))[1],'#' , /extract))[0]
status.colorchoice=(strsplit((strsplit(dumarr[12], /extract))[1],'#' , /extract))[0]
status.binflux=(strsplit((strsplit(dumarr[13], /extract))[1],'#' , /extract))[0]
status.bincolor=(strsplit((strsplit(dumarr[14], /extract))[1],'#' , /extract))[0]
status.maxcolor=(strsplit((strsplit(dumarr[15], /extract))[1],'#' , /extract))[0]
status.mincolor=(strsplit((strsplit(dumarr[16], /extract))[1],'#' , /extract))[0]
status.maxflux=(strsplit((strsplit(dumarr[17], /extract))[1],'#' , /extract))[0]
status.minflux=(strsplit((strsplit(dumarr[18], /extract))[1],'#' , /extract))[0]


if strmatch(status.colorchoice, '') EQ 0 then begin
split=strsplit(status.maxcolor, ',', /extract)
nsplit=n_elements(split)
cmagold=replicate({f1:'', f2:'', binflux:'200', maxflux:'50', minflux:'-50', $
                        maxcolor:'50', mincolor:'-50', bincolor:'200'}, nsplit)
cmagold.mincolor=strsplit(status.mincolor, ',', /extract)
cmagold.maxcolor=strsplit(status.maxcolor, ',', /extract)
cmagold.bincolor=strsplit(status.bincolor, ',', /extract)
cmagold.minflux=strsplit(status.minflux, ',', /extract)
cmagold.maxflux=strsplit(status.maxflux, ',', /extract)
cmagold.binflux=strsplit(status.binflux, ',', /extract)
split0=strsplit(status.colorchoice, ',', /extract)
for i=0, nsplit-1 do begin
   split1=strsplit(split0[i], '-', /extract)
   cmagold[i].f1=split1[0]
   cmagold[i].f2='-'+split1[1]
endfor
status.cmagson=1
widget_control, status.cmagon, /set_button
widget_control, status.cmagadd, sensitive=1
endif
gui_refresh

end
;-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
pro slug_event, ev
common slugs, status
common processes, proc
common sfh_name, sfh_final_name

widget_control, ev.id, get_uvalue=uvalue
if keyword_set(uvalue) EQ 0 then uvalue=''
case uvalue of
'imf':status.imfchoice=status.imfnames[ev.index]
'feh':status.fehchoice=status.fehnames[ev.index]
'random':status.drawchoice='RANDOM'
'sequntial':status.drawhcoice='SEQUENTIAL'
'maxmass':status.maxclustermass=ev.value
'minmass':status.minclustermass=ev.value
'cmfslope':status.slopecmf=ev.value
'sfh':status.sfh=ev.value
'outname':status.modelname=ev.value
'timestep':status.timestep=ev.value
'maxtime':status.maxtime=ev.value
'nuv':status.fluxes[0]*=-1
'fuv':status.fluxes[1]*=-1
'bol':status.fluxes[2]*=-1
'j':status.fluxes[3]*=-1
'h':status.fluxes[4]*=-1
'k':status.fluxes[5]*=-1
'SDSSu':status.fluxes[6]*=-1
'SDSSg':status.fluxes[7]*=-1
'SDSSr':status.fluxes[8]*=-1
'SDSSi':status.fluxes[9]*=-1
'SDSSz':status.fluxes[10]*=-1
'johnsonU':status.fluxes[11]*=-1
'johnsonB':status.fluxes[12]*=-1
'johnsonV':status.fluxes[13]*=-1
'johnsonR':status.fluxes[14]*=-1
'johnsonI':status.fluxes[15]*=-1
'QH0':status.fluxes[16]*=-1
'run':begin
	write_status
	if keyword_set(proc) EQ 0 then begin
	   proc={procs, obridge:obj_new("IDL_IDLBridge", output=''),$
				 modelname:status.modelname, status:1L, start_time:systime()}
	endif else proc=[proc, {procs, obridge:obj_new("IDL_IDLBridge", output=''), $
				modelname:status.modelname, status:1L, start_time:systime()}]
	npro=n_elements(proc)
	spawn, 'echo $SLUG_DIR', dir
	cd, current=thisdir
	proc[npro-1].obridge->execute, 'cd, "'+thisdir+'"'
	proc[npro-1].obridge->execute, "spawn, '"+dir+"slug "+proc[npro-1].modelname+".param'",/nowait
	status.list_of_procs[npro-1]=proc[npro-1].modelname+'     Started on '+proc[npro-1].start_time+'   Running...'
	widget_control, status.big_list, set_value=status.list_of_procs[0:npro-1]
			
      end
'biglist': status.listsel=ev.index
'view_param':begin
	if status.listsel GE 0 then begin
	openr, lun, proc[status.listsel].modelname+'.param', /get_lun
	dum=''
	dumarr=''
	while ~EOF(lun) do begin
	  readf, lun, dum
	  dumarr=[dumarr, dum]
	endwhile
	close, lun
	rds_popup, status.tlb, text=dumarr
	endif
	end
'copy':begin
	  if status.listsel GE 0 then begin
	  parse_param, proc[status.listsel].modelname+'.param'
	  endif
	end

'make_sfh':begin
	   mksfh, status.tlb, status.maxtime
	   widget_control, status.tlb, time=0.5
	end
'cmag_on':begin
	if total(status.fluxes GT 0) GE 1.9  then begin
	widget_control, status.cmagadd, sensitive=1
	status.cmagson=1
	endif else widget_control, status.cmagoff, set_button=1
	end
'cmag_off':begin
        widget_control, status.cmagadd, sensitive=0
        status.cmagson=-1
        end

'cmagadd':begin
	cmagadd, status.tlb, status
	widget_control, status.tlb, time=0.5
	end

;	end
'kill':begin
	if status.listsel GE 0 then begin
	proc[status.listsel].obridge->abort
	obj_destroy, proc[status.listsel].obridge

	proc[status.listsel].status=-2
	status.list_of_procs[status.listsel]=proc[status.listsel].modelname+$
                                                        '     Started on '+proc[status.listsel].start_time+$
                                                        '     Done...'
	npro=n_elements(proc)
	widget_control, status.big_list, set_value=status.list_of_procs[0:npro-1]
	endif
	end

'top_menu':begin
	  case ev.value of
	   'Quit':uvalue='quit'
	   'Open':begin
		    res=rds_fileselect(theobject, base=status.tlb,$
					 filter='*.param')
		    if keyword_set(res) then parse_param, res
		  end
	   else: 
	  endcase
	end

else: if keyword_set(uvalue) then print, uvalue
endcase


	;   while keyword_set(sfh_final_name) EQ 0 do begin
;		help, sfh_final_name
;		
;	   endwhile
;;	   res=sfh_final_name
;	   if strmatch(res, 'bad_exit_123456') EQ 0 then begin
;	     status.sfr=-1
;	     status.sfh=res
;	   endif
;	   gui_refresh


IF (TAG_NAMES(ev, /STRUCTURE_NAME) EQ 'WIDGET_TIMER') then begin
	widget_control, ev.top, timer=0.1
	if keyword_set(proc) then begin
	  change=0
	  for i=0, n_elements(proc)-1 do begin
	     npro=n_elements(proc)
	     if proc[i].status GT 0 then proc[i].status=proc[i].obridge->status() 
	     if proc[i].status EQ -1 then proc[i].status=((proc[i].obridge->status() EQ 0)?-2:-1) 
	     if proc[i].status EQ 0 then begin
;		obj_destroy, proc[i].obridge
		status.list_of_procs[i]=proc[i].modelname+$
						'     Started on '+proc[i].start_time+$
						'     Parsing...'
		change=1
		proc[i].status=-1
		proc[i].obridge->execute, 'read_slug, "'+proc[i].modelname+'"'
	     endif
	     if proc[i].status EQ -2 then begin
		obj_destroy, proc[i].obridge
		status.list_of_procs[i]=proc[i].modelname+$
							'     Started on '+proc[i].start_time+$
							'     Done...'
		change=1
		proc[i].status=-3
	     endif
	
             if keyword_set(change) then $
			widget_control, status.big_list, set_value=status.list_of_procs[0:npro-1]
	  endfor
	endif
	if keyword_set(sfh_final_name) then begin
	  if strmatch(sfh_final_name, 'bad_exit_123456') EQ 0 then begin
            status.sfr=-1
            status.sfh=sfh_final_name
          endif
          gui_refresh
	  sfh_final_name=''
	endif

	
endif

widget_control, status.cmagon, sensitive=total(status.fluxes GT 0) GT 1.9
	



if strmatch(uvalue, 'help*') then help_menu, uvalue
if strmatch(uvalue, 'quit') then begin
	widget_control, ev.top, /destroy
	if keyword_Set(proc) then  for i=0, n_elements(proc)-1 do begin
		if proc[i].status LT 0 then continue
		proc[i].obridge->abort
		obj_destroy, proc[i].obridge
		endfor
endif
end

;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
pro slug
common slugs, status
common btns, imfbtn, fehbtn


status={tlb:0L, big_list:0L, imfnames:['KROUPA', 'CHABRIER', 'SALPETER', 'IGIMF'], imfind:0L, imflist:0L,$
		fehnames:['.0004','.001','.004','.008','.020','.040','.100'],fehind:0L, fehlist:0L, $
		menu_ids:lonarr(25), cmagadd:0L, $
		imfbtn:0L, fehbtn:0L, drawbtns:lonarr(2), cmfmaxbtn:0L, cmfminbtn:0L, cmfslopebtn:0L, sfhbtn:0L, outnamebtn:0L,$
		timestepbtn:0L, maxtimebtn:0L, fluxesbtn:lonarr(17), $
		fluxes:lonarr(17)-1, cmagon:0L, cmagoff:0L,$
		timestep:'1E6', maxtime:'3E6', sfr:'1', sfh:'mysfh.txt', imfchoice:'KROUPA', $
		fehchoice:'.020', modelname:'test1', maxclustermass:'1E7',$
		minclustermass:'20',$
		slopecmf:'-2', drawchoice:'RANDOM', flux_choice:'NUV,FUV', $
		colorchoice:'FUV-NUV', binflux:'200', bincolor:'200', maxcolor:'50',$
		mincolor:'-50', maxflux:'50', minflux:'-50', list_of_procs:strarr(1000), time_of_check:0.,$
		listsel:-1L, cmagson:-1}

status.tlb=widget_base(title='SLUG: Stochastically Lighting Up Galaxies', $
	xsize=1034, ysize=768, /column, app_mbar=top_menu)

;Make the pull-down menu
tmp_struct = {cw_pdmenu_s, flags:0, name:''}

top_menu_desc = [ $
                  {cw_pdmenu_s, 1, 'File'}, $ ; file menu ;flags 1 starts a menu
                  {cw_pdmenu_s, 0, 'Setup'}, $		;0 is an entry
                  {cw_pdmenu_s, 0, 'Open'},  $		;2 ends a menu
                  {cw_pdmenu_s, 2, 'Quit'}, $
		  {cw_pdmenu_s, 1, 'Help'},$
                  {cw_pdmenu_s, 2, 'Example'},$
		  {cw_pdmenu_s, 1, 'How to Cite'},$
                  {cw_pdmenu_s, 2, 'Explanation'} ]

top_menu = cw_pdmenu(top_menu, top_menu_desc, $
                     ids = status.menu_ids, $
                     /mbar, $
                     /help, $
                     /return_name, $
                     uvalue = 'top_menu')
qval=' ? '
row1=widget_base(status.tlb, /row)
col1=widget_base(row1, /col)
topcol1=widget_base(col1, col=1, /frame)
lbl=widget_label(topcol1, value='Physical Properties', /align_center)
row00=widget_base(topcol1, /row)
imfbtn=fsc_droplist(row00, value=status.imfnames, uvalue='imf', title='IMF Type         ')
btn=widget_button(row00, value=qval, uvalue='help_imf')
row00=widget_base(topcol1, /row)
fehbtn=fsc_droplist(row00, value=status.fehnames, uvalue='feh', title='Metallicity      ')
btn=widget_button(row00, value=qval, uvalue='help_feh')

;topcol2=widget_base(col1, col=1, /frame)
topcol2=topcol1
;lbl=widget_label(topcol2, value='Star Formation Properties', /align_center)
drawrow=widget_base(topcol2, /row)
lbl=widget_label(drawrow, value='Draw Type:       ')
base0=widget_base(drawrow, /exclusive, /row)
status.drawbtns[0]=widget_button(base0, value='Random', uvalue='random')
status.drawbtns[1]=widget_button(base0, value='Sequential', uvalue='sequential')
btn=widget_button(drawrow, value=qval, uvalue='help_draw')
row00=widget_base(topcol2, /row)
status.cmfmaxbtn=cw_field(row00, title='Max Cluster Mass:', value='1E7', /all, uvalue='maxmass')
btn=widget_button(row00, value=qval, uvalue='help_maxmass')
row00=widget_base(topcol2, /row)
status.cmfminbtn=cw_field(row00, title='Min Cluster Mass:', value='20', /all, uvalue='minmass')
btn=widget_button(row00, value=qval, uvalue='help_minmass')
row00=widget_base(topcol2, /row)
status.cmfslopebtn=cw_field(row00, title='CMF Slope        ', value='-2', /all, uvalue='cmfslope')
btn=widget_button(row00, value=qval, uvalue='help_cmfslope')
row00=widget_base(topcol2, /row)
status.sfhbtn=cw_field(row00, title='SFH:             ', value='1', /all, uvalue='sfh')
btn=widget_button(row00, value='Make', uvalue='make_sfh')
btn=widget_button(row00, value=qval, uvalue='help_sfh')

read_jpeg, '$SLUG_DIR/slug3.jpeg', slugimage

col00=widget_base(row1, /col)
logo=widget_draw(col00, xsize=336, ysize=221, uvalue='logo')
col0=widget_base(col00, /col, /frame)
lbl=widget_label(col0, /align_center, value='Simulation Properties')
row00=widget_base(col0, /row)
status.outnamebtn=cw_field(row00, title='Model Name:      ', value=status.modelname, /all, uvalue='outname')
btn=widget_button(row00, value=qval, uvalue='help_name')
row00=widget_base(col0, /row)
status.timestepbtn=cw_field(row00, title='Timestep:        ', value='1E6', /all, uvalue='timestep')
btn=widget_button(row00, value=qval, uvalue='help_timestep')
row00=widget_base(col0, /row)
status.maxtimebtn=cw_field(row00, title='Max Time:        ', value='3E6', /all, uvalue='maxtime')
btn=widget_button(row00, value=qval, uvalue='help_maxtime')


topcol3=widget_base(row1, /col, /frame)
lbl=widget_label(topcol3, value='Output', /align_center)
drawrow=widget_base(topcol3, /col, /frame)
row00=widget_base(drawrow, /row, /align_center)
lbl=widget_label(row00, value='Fluxes:')
btn=widget_button(row00, value=qval, uvalue='help_fluxes')
base0=widget_base(drawrow, /nonexclusive, col=5)
status.fluxesbtn[0]=widget_button(base0, value='NUV', uvalue='nuv')
status.fluxesbtn[1]=widget_button(base0, value='FUV', uvalue='fuv')
status.fluxesbtn[2]=widget_button(base0, value='BOL', uvalue='bol')
status.fluxesbtn[3]=widget_button(base0, value='J', uvalue='j')
status.fluxesbtn[4]=widget_button(base0, value='H', uvalue='h')
status.fluxesbtn[5]=widget_button(base0, value='K', uvalue='k')
status.fluxesbtn[6]=widget_button(base0, value='SDSSu', uvalue='SDSSu')
status.fluxesbtn[7]=widget_button(base0, value='SDSSg', uvalue='SDSSg')
status.fluxesbtn[8]=widget_button(base0, value='SDSSr', uvalue='SDSSr')
status.fluxesbtn[9]=widget_button(base0, value='SDSSi', uvalue='SDSSi')
status.fluxesbtn[10]=widget_button(base0, value='SDSSz', uvalue='SDSSz')
status.fluxesbtn[11]=widget_button(base0, value='johnsonU', uvalue='johnsonU')
status.fluxesbtn[12]=widget_button(base0, value='johnsonB', uvalue='johnsonB')
status.fluxesbtn[13]=widget_button(base0, value='johnsonV', uvalue='johnsonV')
status.fluxesbtn[14]=widget_button(base0, value='johnsonR', uvalue='johnsonR')
status.fluxesbtn[15]=widget_button(base0, value='johnsonI', uvalue='johnsonI')
status.fluxesbtn[16]=widget_button(base0, value='QH0', uvalue='QH0')


drawrow=widget_base(topcol3, /col, /frame)
row00=widget_base(drawrow, /row, /align_center)
lbl=widget_label(row00, value='Color Mag Diagrams:')
base0=widget_base(row00, /exclusive, /row)
status.cmagon=widget_button(base0, value='On', uvalue='cmag_on')
status.cmagoff=widget_button(base0, value='Off', uvalue='cmag_off')
btn=widget_button(row00, value=qval, uvalue='help_colormag')
row00=widget_base(drawrow, /row, /align_center)
status.cmagadd=widget_button(row00, value='Add/Remove a CMD', uvalue='cmagadd', sensitive=0)
btn=widget_button(row00, value=qval, uvalue='help_addcolormag')






row2=widget_base(status.tlb, /row, /align_center)
btn1=widget_button(row2, value='Run Process', uvalue='run')
btn1=widget_button(row2, value='View Param File', uvalue='view_param')
btn1=widget_button(row2, value='Copy Process', uvalue='copy')
btn1=widget_button(row2, value='Grid Process', uvalue='grid', sensitive=0)
btn1=widget_button(row2, value='Kill Process', uvalue='kill')
btn=widget_button(row2, value=qval, uvalue='help_running')


status.big_list=widget_list(status.tlb, scr_ysize=300, uvalue='biglist')


lbl=widget_label(status.tlb, /align_center, value='da Silva, Fumagalli, & Krumholz')

widget_control, status.tlb, /realize
widget_control, logo, get_value=winid
wset, winid
tv, slugimage, true=1
widget_control, status.tlb, timer=0.1
widget_control, status.drawbtns[0], /set_button
widget_control, status.cmagoff, /set_button

fehbtn->setindex, 4
xmanager, 'slug', status.tlb, /no_block
end
